package com.gitee.feizns.webtemplate.entity.vo.commons.page;

import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @author feizns
 * @since 2019/5/13
 */
public class FvPageImplForSpringData<T> implements FvPage<T> {

    /**
     *
     */
    private Page<T> page;

    public FvPageImplForSpringData(org.springframework.data.domain.Page<T> page) {
        this.page = page;
    }

    @Override
    public Integer getBeginPos() {
        return page.getNumber() * page.getSize();
    }

    @Override
    public Integer getCurtPage() {
        return page.getNumber() + 1;
    }

    @Override
    public Integer getPageSize() {
        return page.getSize();
    }

    @Override
    public Long getPageCount() {
        return Long.valueOf(page.getTotalPages());
    }

    @Override
    public long getTotal() {
        return page.getTotalElements();
    }

    @Override
    public List<T> getRows() {
        return page.getContent();
    }

}
